// lib/pojo/UserModel.dart
import 'package:json_annotation/json_annotation.dart';

@JsonSerializable()
class User {
  final int id;
  final String username;
  final String password;
  final String email;
  final String token;




  User({required this.id, required this.username, required this.email, required this.password, required this.token});

  // 手动实现 fromJson 方法
  factory User.fromJson(Map<String, dynamic> json) {
    return User(
      id: json['id'] as int,
      username: json['username'] as String,
      email: json['email'] as String,
      password: json['password'] as String,
      token: json['token'] as String,
    );
  }

  // 手动实现 toJson 方法
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'username': username,
      'email': email,
      'password': password,
      'token': token,
    };
  }
}